from flask import Flask,jsonify,request,Blueprint
from common.res import (getRes,getErrorRes,getSuccessRes)

from DAL.systemManageDAL import systemManageDAL

userManage = Blueprint('userManage',__name__)

@userManage.route("/get_module",methods=['POST','GET'])
def get_module():
    user_id = request.form.get('user_id') or ''
    dal = systemManageDAL()
    data = dal.getModule(user_id)
    res = getSuccessRes(data=data)
    return jsonify(res)

@userManage.route("/get_account_by_code",methods=['POST','GET'])
def getAccountByCode():
    right_code = request.form.get('right_code') or ''
    dal = systemManageDAL()
    data = dal.getAccountByCode(right_code)
    res = getSuccessRes(data=data)
    return jsonify(res)

@userManage.route("/update_account_token",methods=['POST','GET'])
def updateAccountToken():
    right_code = request.form.get('right_code') or ''
    token = request.form.get('token') or ''
    dal = systemManageDAL()
    data = dal.updateAccountToken(right_code,token)
    res = getSuccessRes(data=data)
    return jsonify(res)
